#ifndef SW_MONITOR_H
#define SW_MONITOR_H
#include "SW1248.h"
#include "I2CSlave.h"

class SWMonitor:public Scheduler
{
public:
    struct _model_function_object {
        
        struct _class;
        union{
            void (*_func)();
            void (_class::*_method)();
        };

        void *obj;
    };

    SWMonitor(SW1248& sw1248);
    ~SWMonitor();

    void schedule() override;
    void update() override;
    void cleanup()override;

    template<typename T,typename U>
    void attach(U *obj,void(T::*method)())
    {
        _store_obj.obj = obj;
        _store_obj._method = reinterpret_cast<decltype(_model_function_object::_method)>(method);
    }
    void attach(void (*func)())
    {
        _store_obj._func = func;
    }
private:
    SW1248& _sw1248;
    _model_function_object _store_obj;
};

#endif